<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return['ischecklogin']=$this->model('member')->get_member();
if($_RQ['op']=='get'){
	$_SESSION['forward_url']='jy_ailiao/member.index/';
	$_SESSION['indexurl']='jy_ailiao/index/';
	$return['item']=model('core/member')->detail($_SESSION['uid']);
	$credit_types=credit_types();
	$pay=uni_setting('pay');
	foreach($credit_types as $k=>$cv){
		if($k>2){
			$prizeType[]=array(
				'id'=>$k,
				'title'=>$cv,
				'api'=>$pay['credit'.$k.'_api'],
				'data'=>$return['item']['credit'.$k],
			);
		}
	}
	$return['item']['credit_type']=$prizeType;
	$member=$this->model('member')->get_member();
	$member['nickname']=$member['nickname']?:$return['item']['nickname'];
	$member['avatar']=$member['avatar']?:$return['item']['avatar'];
	$member['images']=$member['images']?json_decode($member['images'],true):array();
	$member['birth']=$member['birth']?json_decode($member['birth'],true):array('year'=>'1996','month'=>'10','day'=>'18');
	$member['pcd']=json_decode($member['pcd'],true);
	$member['jiguan']=json_decode($member['jiguan'],true);
	$member['avatar']=$member['avatar']?:$item['images'][0];
	$member['sextitle']=$this->sex[$member['sex']];
	$member['picsnum']=count($member['images']);
	$current_year=date('Y');
	$member['age'] = $member['birth']['year']?$current_year - $member['birth']['year'] - 1:'**';
	$member['percent']=$this->model('member')->getpercent($member);
	$member['height']=$member['height']>90?30:$member['height'];
	$member['height']=$member['height']?:30;
	$member['lat_lng']=$this->session('lat_lng')?:json_decode($member['lat_lng'],true);
	$member['islat']=intval($member['lat_lng']['lat']);
	$return['member']=$member;
	$tomember=$this->model('member')->get_tomember();
	$tomember['pcd']=json_decode($tomember['pcd'],true);
	$tomember['age'] = $tomember['birth']['year']?$current_year - $tomember['birth']['year'] - 1:'**';
	$return['tomember']=$tomember;
	$return['years']=array();
	for($i=1920;$i<2006;$i++){
		$return['years'][]=$i;
	}
	$return['months']=array(1,2,3,4,5,6,7,8,9,10,11,12);
	$return['days']=array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
	$return['sex']=$this->sex;
	$return['xueli']=$this->xuelis;
	$return['jiehun']=$this->jiehuns;
	$return['shouru']=$this->shourus;
	$return['youboy']=$this->youboy;
	$return['wanboy']=$this->wanboy;
	$return['goufang']=$this->goufang;
	$return['gouche']=$this->gouche;
	$return['height']=$this->heights;
	$return['weight']=$this->weights;
	$return['tixing']=$this->tixing;
	$return['xiyan']=$this->xiyan;
	$return['hejiu']=$this->hejiu;
	$return['xingzuo']=$this->xingzuo;
	$return['jh_time']=$this->jh_time;
	$return['minzu']=$this->model('model')->minzus();
	$return['zhiwei']=$this->model('model')->zhiweis();
	$return['pcd']=array('city'=>$member['city']);
	set_html('title','会员中心');
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if($postdata['birth'] && $_SESSION['os']=='wxapp'){
		$postdata['birth']=explode('-',$postdata['birth']);
		$postdata['birth']=array(
				'year'=>$postdata['birth'][0],
				'month'=>$postdata['birth'][1],
				'day'=>$postdata['birth'][2],
		);
	}
	$postdata['lat_lng']=$postdata['lat_lng']?:$this->session('lat_lng');
	$data=array(
		'mobile'=>trim($postdata['mobile']),
		'nickname'=>trim($postdata['nickname']),
		'realname'=>trim($postdata['realname']),
		'desc'=>trim($postdata['desc']),
		'email'=>trim($postdata['email']),
		'avatar'=>trim($postdata['avatar']),
		'images'=>ijson_encode($postdata['images']),
		'qq'=>trim($postdata['qq']),
		'wechat'=>trim($postdata['wechat']),
		'city'=>$postdata['pcd']['city'],
		'pcd'=>ijson_encode($postdata['pcd']),
		'jiguan'=>ijson_encode($postdata['jiguan']),
		'address'=>trim($postdata['address']),
		'lat_lng'=>ijson_encode($postdata['lat_lng']),
		'birth'=>ijson_encode($postdata['birth']),
		'year'=>trim($postdata['birth']['year']),
		'sex'=>trim($postdata['sex']),
		'isjiehun'=>trim($postdata['isjiehun']),
		'xueli'=>trim($postdata['xueli']),
		'shouru'=>trim($postdata['shouru']),
		'youboy'=>intval($postdata['youboy']),
		'wanboy'=>trim($postdata['wanboy']),
		'goufang'=>trim($postdata['goufang']),
		'gouche'=>trim($postdata['gouche']),
		'weight'=>trim($postdata['weight']),
		'height'=>trim($postdata['height']),
		'tixing'=>trim($postdata['tixing']),
		'xiyan'=>trim($postdata['xiyan']),
		'hejiu'=>trim($postdata['hejiu']),
		'xingzuo'=>trim($postdata['xingzuo']),
		'minzu'=>trim($postdata['minzu']),
		'zhiwei'=>trim($postdata['zhiwei']),
		'jh_time'=>trim($postdata['jh_time']),
	);
	$this->update('member',$data,array('id'=>$postdata['id']));
	exi('提交成功！');
}
if($_RQ['op']=='password'){
	$post=get_postdata();
	if(!$post['password']){
		exi('请输入支付密码！','erroe');
	}
	pdo_update('core_members',array('paypassword'=>$post['password']),array('id'=>$_SESSION['uid']));
	exi('设置成功！');
}